<?php
require('../lib/forms/form2rdf.php');
require('../lib/forms/formfilter.php');

class form2rdf_TestCase extends PHPUnit_TestCase {
	
	var $f;
	var $post = array(
		'rdf:RDF' => array(
			'foaf:Person' => array(
				'rdf:about' => 'http://keithalexander.co.uk/#me',
				'foaf:name@en' => 'Keith Alexander',
				),
			),
		
		);
	function __construct($name)
	{
		$this->PHPUnit_TestCase($name);
	}
	function setUp(){
		$this->f = new Form2RDF();
	}
	
	function tearDown(){
		unset($this->f);
	}
	
	function test_array2rdf()
	{
		$act = $this->f->array_to_rdfxml($this->post);
		$ex = <<<_RDF_
<rdf:RDF><foaf:Person rdf:about="http://keithalexander.co.uk/#me"><foaf:name  xml:lang="en">Keith Alexander</foaf:name></foaf:Person></rdf:RDF>
_RDF_;
		$this->assertEquals(trim($ex), trim($act));
	}
	
	function test_process_POST()
	{
		$formXML = <<<_XML_
		<div>
		
			<form method="post">
				<input name="rdf:RDF[foaf:Person][rdf:about]" />
				<input name="rdf:RDF[foaf:Person][foaf:name@en]"/>
				<div><input type="submit" value="Save"/></div>
			</form>

	
		</div>
_XML_;
		$formProcessor = new FormFilter();
		$act = $this->f->process_POST($formXML, $this->post, $formProcessor);
		
		$ex = array(
			'rdf:RDF' => array(
				'foaf:Person' => array(
					'rdf:about' => 'http://keithalexander.co.uk/#me',
					'foaf:name@en' => 'Keith Alexander',
					),
				),

			);
			
		$this->assertTrue($act==$ex);
		
	}
	
	
}

?>